# -*- coding: UTF-8 -*-
import os
import create_mssql_trigger
import create_mysql_trigger

# 递归遍历目录
def traversal_files(path):
    for dir in os.listdir(path):
        dir = os.path.join(path, dir)
        dir = dir.replace("\\", "/")

        # print(dir)
        # 判断当前目录是否为文件夹
        if os.path.isdir(dir):
            dir_words = dir.split("/")
            dir_index = len(dir_words) - 1
            cur_dir = dir_words[dir_index]
            if("mssql" in cur_dir):
                create_mssql_trigger.create_mssql_insert_trigger(dir)
                create_mssql_trigger.create_mssql_update_trigger(dir)
                create_mssql_trigger.create_mssql_delete_trigger(dir)
            if("mysql" in cur_dir):
                create_mysql_trigger.create_cols_mappings(dir)
            traversal_files(dir)

if __name__ == '__main__':
    path = "C:/APS/export/mapping"
    traversal_files(path)